@extends('layout.main')

@section('css')
<link rel="stylesheet" href="/assets/js/plugins/jstree/themes/default/style.min.css" />
@endsection

@section('content')
<div class="row">
    <div class="col-lg-12">
        <div class="ibox float-e-margins">
            <div>
                <form id="form" method="post" class="form-horizontal" action="/admin/edit">
                    <input type="hidden" name="id" value="{{$info['admin']->id}}">
                    <div class="form-group"><label class="col-sm-2 control-label">用户名</label>
                        <div class="col-sm-10"><input type="text" name="username" value="{{$info['admin']->username}}" class="form-control"></div>
                    </div>
                    
                    <div class="hr-line-dashed"></div>
                    
                    <div class="form-group"><label class="col-sm-2 control-label">姓名</label>
                        <div class="col-sm-10"><input type="text" name="fullname" value="{{$info['admin']->fullname}}" class="form-control"></div>
                    </div>

                    <div class="hr-line-dashed"></div>
                    
                    <div class="form-group"><label class="col-sm-2 control-label">手机</label>
                        <div class="col-sm-10"><input type="text" name="phone" value="{{$info['admin']->phone}}" class="form-control"></div>
                    </div>

                    <div class="hr-line-dashed"></div>
                    
                    <div class="form-group"><label class="col-sm-2 control-label">Email</label>
                        <div class="col-sm-10"><input type="text" name="email" value="{{$info['admin']->email}}" class="form-control"></div>
                    </div>
                    
                    <div class="hr-line-dashed"></div>

                    <div class="form-group"><label class="col-sm-2 control-label">性别</label>

                        <div class="col-sm-10">
                            <div>
                            <label><input type="radio" name="gender" @if ($info['admin']->gender==1) checked="checked" @endif value="1">男</label>
                            <label><input type="radio" name="gender" @if ($info['admin']->gender==0) checked="checked" @endif value="0">女</label>
                            </div>
                        </div>
                    </div>
                  
                    <div class="hr-line-dashed"></div>

                    <div class="form-group"><label class="col-sm-2 control-label">所属角色</label>

                        <div class="col-sm-10"><select class="form-control m-b" name="role_id">
                            <option value="">请选择</option>
                            @foreach ($info['roles'] as $role)
                            <option value="{{$role->id}}" @if ($info['admin']->role_id==$role->id) selected="selected" @endif>{{$role->name}}
                            </option>
                            @endforeach
                        </select>
                        </div>
                    </div>
                    <div class="hr-line-dashed"></div>

                    <div class="form-group"><label class="col-sm-2 control-label">状态</label>

                        <div class="col-sm-10">
                            <div>
                            <label><input type="radio" name="status_at" @if ($info['admin']->status_at==1) checked="checked" @endif value="1">启用</label>
                            <label><input type="radio" name="status_at" @if ($info['admin']->status_at==0) checked="checked" @endif value="0">禁用</label>
                            </div>
                        </div>
                    </div>
                   
                    <div class="hr-line-dashed"></div>
                   {!! csrf_field() !!}
                    <div class="form-group">
                        <div class="col-sm-4 col-sm-offset-2">
                            <button class="btn btn-white" type="reset">取消</button>
                            <button class="btn btn-primary" type="submit">保存</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
@endsection

@section('js')
<script src="/assets/js/plugins/jstree/jstree.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
    $("#form").validate({
        rules: {
            username: {
                required: true
            },
            fullname: {
                required: true
            },
            phone: {
                required: true
            },
            email:{
                required:true,
                email:true
            },
            gender: {
                required: true
            },
            role_id:{
                required: true
            }
        },
        messages: {
            username: "请填写用户名",
            fullname: "请填写姓名",
            phone: "请填写手机",
            email: "请填写正确的Email",
            gender: "请填写性别",
            role_id: "请选择角色"
        }
    });
});
</script>
@endsection